package com.zhangwei.day38.fragment;


import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.BitmapDisplayConfig;
import com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack;
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom;
import com.zhangwei.day38.R;
import com.zhangwei.day38.utils.XutilsHelper;

/**
 * 1,全局配置
 * 2,显示配置
 * 3清理缓存
 * orm dao 都是值对数据库的操作
 *
 */
public class BitmapFragment extends Fragment {
    private ImageView img;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_bitmap, container, false);
        BitmapUtils bitmapUtils = new BitmapUtils(getActivity());
        bitmapUtils.configDefaultLoadingImage(R.mipmap.ic_launcher);
        bitmapUtils.clearDiskCache();


//        ListView listview ;
//        listview.setOnScrollListener(new PauseOnScrollListener(bitmapUtils));
        bitmapUtils.display(img, "", XutilsHelper.getInstance().getDefBitmapDisplayOption(getActivity()));
        bitmapUtils.display(img, "", XutilsHelper.getInstance().getDefBitmapDisplayOption(getActivity()), new BitmapLoadCallBack<ImageView>() {

            @Override
            public void onLoading(ImageView container, String uri, BitmapDisplayConfig config, long total, long current) {
                super.onLoading(container, uri, config, total, current);
            }

            @Override
            public void onLoadCompleted(ImageView container, String uri, Bitmap bitmap, BitmapDisplayConfig config, BitmapLoadFrom from) {

            }

            @Override
            public void onLoadFailed(ImageView container, String uri, Drawable drawable) {

            }
        });



        return view;
    }


}
